fix: guard escrow time arithmetic, escrow approval states, role count, and segment member_count - #744
Open
Akpolo wants to merge 1 commit into
Open
Conversation
…, and segment member_count - audience-segments: keep Segment.member_count in sync when members are added or removed, instead of leaving it permanently at 0 - governance-core: revoke_role only removes and decrements RoleCount when the grant actually exists, preventing a double decrement after has_role lazily cleans an expired grant - escrow-vault: approve_release rejects Refunded and Disputed escrows in addition to Released - escrow-vault: create_escrow computes time_lock_until and expires_at with checked_add so u64 overflow panics instead of wrapping to the past Closes ThinkLikeAFounder#721 Closes ThinkLikeAFounder#722 Closes ThinkLikeAFounder#723 Closes ThinkLikeAFounder#724
|
@Akpolo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
add_memberandremove_membernow updateSegment.member_count(andlast_updated) alongside theMemberCount(segment_id)key, soget_segmentno longer reportsmember_count = 0regardless of actual membership.revoke_rolenow checks that theRoleGrantentry actually exists before removing it and decrementingRoleCount, preventing the double decrement whenhas_rolehas already lazily cleaned an expired grant.approve_releasenow rejects all terminal states —Released,Refunded, andDisputed— instead of onlyReleased, so closed or locked escrows can no longer accumulate meaningless approvals.create_escrowcomputestime_lock_untilandexpires_atwithchecked_add, panicking on u64 overflow instead of wrapping to a past timestamp (which would have bypassed the time lock or made the escrow instantly refundable).Note: the existing
test_release_disputed_escrow_failstest approved a disputed escrow before attempting release; with the #723 guard the approval itself now panics, so the test was reordered to approve before the dispute — its release-path assertion is unchanged.Test plan
cargo testincontracts/audience-segments— 9 passed (new:test_segment_member_count_stays_in_sync)cargo testincontracts/governance-core— 12 passed (new:test_revoke_after_expiry_cleanup_no_double_decrement)cargo testincontracts/escrow-vault— 32 passed (new:test_approve_release_refunded_fails,test_approve_release_disputed_fails,test_create_escrow_time_lock_overflow,test_create_escrow_expires_at_overflow)Closes #721
Closes #722
Closes #723
Closes #724